home *** CD-ROM | disk | FTP | other *** search
- {$APPTYPE CONSOLE}
- {$I-}
- uses
- SysUtils, DrBobDOS;
- var
- f: Text;
- i: Integer;
- Back,Str: ShortString;
- SRec: TSearchRec;
-
- var
- Data: ShortString;
-
- function Value(Const Field: ShortString): ShortString;
- var
- i: Integer;
- begin
- Result := '';
- i := Pos(Field+'=',Data);
- if i > 0 then
- begin
- Inc(i,Length(Field)+1);
- while Data[i] <> '&' do
- begin
- Result := Result + Data[i];
- Inc(i)
- end
- end
- end {Value};
-
- var
- ContentLength: Integer;
-
- begin
- writeln('Content-type: text/html');
- writeln;
- writeln('<HTML>');
- writeln('<BODY>');
- writeln('<H1>Dr.Bob''s HITs Counter</H1>');
- writeln('<HR>');
- with TBDosEnvironment.Create(nil) do
- try
- for i:=0 to Pred(DosEnvCount) do
- begin
- if Pos('REQUEST_METHOD',DosEnvList[i]) > 0 then
- begin
- Data := DosEnvList[i];
- Delete(Data,1,Pos('=',Data))
- end
- end;
- if Data = 'POST' then
- begin
- ContentLength := StrToInt(GetDosEnvStr('CONTENT_LENGTH'));
- for i:=1 to ContentLength do read(Data[i]);
- Data[ContentLength+1] := '&' { catch-all }
- end
- else ContentLength := 0
- finally
- Free
- end;
- if ContentLength = 0 then
- begin
- writeln('<FORM ACTION="/cgi-bin/counted.exe?" METHOD=POST>');
- writeln('Please specify the day to analyse:<BR>');
- writeln('<SELECT NAME="log">');
- if FindFirst('*.log',faArchive,SRec) = 0 then
- repeat
- writeln('<OPTION VALUE="',SRec.Name,'"> ',Copy(SRec.Name,1,4),'/',Copy(SRec.Name,5,2),'/',Copy(SRec.Name,7,2));
- until FindNext(SRec) <> 0;
- writeln('</SELECT>');
- FindClose(SRec);
- writeln('<P>');
- writeln('<INPUT TYPE="RESET" VALUE="Reset">');
- writeln('<INPUT TYPE="SUBMIT" VALUE="Get Hit Count Statistics">');
- writeln('</FORM>');
- end
- else
- begin
- writeln('<CENTER>');
- writeln('<TABLE BORDER>');
- writeln('<TR><TD BGCOLOR="A7B7C7">No.</TD><TD BGCOLOR="A7B7C7">Date</TD><TD BGCOLOR="A7B7C7">Time</TD><TD BGCOLOR="A7B7C7">IP</TD><TD BGCOLOR="A7B7C7">Host</TD></TR>');
- System.Assign(f,Value('log'));
- reset(f);
- if IOResult = 0 then while not eof(f) do
- begin
- readln(f,Str);
- Str[Length(Str)+1] := #0;
- write('<TR><TD',Back,'>');
- i := 0;
- repeat
- Inc(i);
- write(Str[i])
- until Str[i+1] = ':';
- write('</TD><TD',Back,'>');
- repeat
- Inc(i);
- until Str[i+1] <> ' ';
- repeat
- Inc(i);
- write(Str[i])
- until Str[i+1] = ' ';
- write('</TD><TD',Back,'>');
- repeat
- Inc(i);
- until Str[i+1] <> ' ';
- repeat
- Inc(i);
- write(Str[i])
- until Str[i] = 'M';
- write('</TD><TD',Back,'>');
- repeat
- Inc(i);
- until Str[i+1] <> ' ';
- repeat
- Inc(i);
- write(Str[i])
- until i = Length(Str);
- write('</TD><TD',Back,'>');
- writeln('</TD></TR>')
- end;
- close(f);
- writeln('</TABLE>');
- writeln('</CENTER>')
- end;
- writeln('</BODY>');
- writeln('</HTML>')
- end.
-